<template>
	<view class="wrap">
		<!-- <view class="nav">
			<view class="nav-item" :class="{active: navIndex == 1}" @click="onNavTap(1)">系统通知</view>
			<view class="nav-item" :class="{active: navIndex == 2}" @click="onNavTap(2)">订单通知</view>
		</view> -->
		<view class="list">
			<view class="item" v-if="navIndex==1" v-for="(item, index) in sysAlertList" :key="index">
				<view class="date">{{item.createTime}}</view>
				<view class="msgList">
					<view class="msgItem" @click="onSkipTap('msgDetail', index)">
						<!-- <view class="msgItem-title app_ellipsis" :class="{noRead: !item.isRead}">{{item.noticeTitle}}</view> -->
						<view class="msgItem-title app_ellipsis">{{item.noticeTitle}}</view>
						<view class="msgItem-content app_ellipsis2">{{item.noticeContent}}</view>
						<view class="msgItem-footer app_arrow">
							<text>查看详情</text>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- <view v-if="navIndex==2" v-for="(item, index) in orderAlertList" :key="index">
			<view class="date">{{item.createTime}}</view>
			<view class="msgList">
				<view class="msgItem" @click="onSkipTap('msgDetail', index)">
					<view class="msgItem-title app_ellipsis" :class="{noRead: !item.isRead}">{{item.title}}</view>
					<view class="msgItem-content app_ellipsis2">{{item.alert}}</view>
					<view class="msgItem-footer app_arrow">
						<text>查看详情</text>
					</view>
				</view>
			</view>
		</view> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				navIndex: 1,
				sysAlertList: [],
				orderAlertList: [],
				noMore: false,
				hasLoad: false,
				page: 1,
				size: 10
			}
		},
		onLoad(options) {
			this.getMsgList()
		},
		onUnload() {
			uni.$off('update-updateMsgList', this.getMsgList)
		},
		onPullDownRefresh() {
			this.getMsgList()
		},
		onReachBottom() {
			this.page++
			this.getMsgList()
		},
		methods: {
			resetPage() {
				this.page = 1
				this.hasLoad = false
				this.noMore = false
				this.offerNewsList = []
			},
			onNavTap(index) {
				this.navIndex = index
			},
			onSkipTap(type, index) {
				let sysMsgItem = this.sysAlertList[index]
				if (sysMsgItem) {
					uni.navigateTo({
						url: `/pages/msg/sysMsgDetail?msgInfo=${JSON.stringify(sysMsgItem)}`
					})
				}
			},
			getMsgList() {
				this.$g_api.sysnoticeList({
					pageNum: this.page,
					pageSize: this.size
				}).then(({
					data
				}) => {
					this.hasLoad = true
					if (data && data.rows && data.rows.length > 0) {
						this.sysAlertList = this.sysAlertList.concat(data.rows)
					} else {
						this.noMore = true
					}
				})
			}
		}
	}
</script>

<style scoped lang="scss">
	.app_arrow {
		&::after {
			right: 10rpx;
			width: 14rpx;
			height: 14rpx;
		}
	}
	
	.wrap {
		// padding-top: 88rpx;
	}
	
	.nav {
		position: fixed;
		top: 0;
		left: 0;
		width: 100vw;
		display: flex;
		background-color: #fff;
		z-index: 999;
	}
	
	.nav-item {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
		line-height: 88rpx;
	
		&.active {
			border-bottom: 2px solid #3377FF;
		}
	}
	
	.date {
		padding: 40rpx 0 30rpx;
		text-align: center;
		font-size: 26rpx;
		color: #999999;
	}
	
	.list {
		padding-bottom: 10rpx;
	}
	
	.msgList {}
	
	.msgItem {
		padding: 30rpx 30rpx 0;
		margin: 0 auto 20rpx;
		width: 710rpx;
		background: #FFFFFF;
		border-radius: 10rpx;
	}
	
	.msgItem-title {
		line-height: 30rpx;
		font-size: 30rpx;
		font-weight: bold;
		color: #333333;
	}
	
	.noRead {
		position: relative;
		padding-left: 20rpx;
	
		&::after {
			display: block;
			position: absolute;
			left: 4rpx;
			top: 50%;
			transform: translateY(-50%);
			content: '';
			width: 10rpx;
			height: 10rpx;
			border-radius: 50%;
			background-color: red;
		}
	}
	
	.msgItem-content {
		margin: 28rpx 0 30rpx;
		font-size: 24rpx;
		color: #999999;
	}
	
	.msgItem-footer {
		display: flex;
		align-items: center;
		height: 90rpx;
		line-height: 90rpx;
		border-top: 1px solid #f2f2f2;
		box-sizing: border-box;
		font-size: 24rpx;
		color: #333333;
	}
	
	.noMore {
		font-size: 28rpx;
		color: #999;
		line-height: 80rpx;
		text-align: center;
		padding-bottom: 20rpx;
	}
	
	.noData {
		height: 80vh;
		ont-size: 28rpx;
		color: #999;
		text-align: center;
		display: flex;
		align-items: center;
		justify-content: center;
	}
</style>
